#define NOTE_F1 350
#define NOTE_F2 393
#define NOTE_F3 441
#define NOTE_F4 495
#define NOTE_F5 556
#define NOTE_F6 624
#define NOTE_F7 661
#define NOTE_0  0
#define NOTE_FL1 175
#define NOTE_FL2 196
#define NOTE_FL3 221
#define NOTE_FL4 234
#define NOTE_FL5 262
#define NOTE_FL6 294
#define NOTE_FL7 330

#define NOTE_FH1 700
#define NOTE_FH2 786
#define NOTE_FH3 882
#define NOTE_FH4 935
#define NOTE_FH5 1049
#define NOTE_FH6 1178
#define NOTE_FH7 1322
#define WHOLE 1
#define HALF 0.5
#define QUARTER 0.25
#define EIGHTH 0.25
#define SIXTEENTH 0.625
int tune[] = //简谱频率
{
  NOTE_F4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_F6,NOTE_F6,NOTE_F6,NOTE_F6,
  NOTE_F5,NOTE_F5,NOTE_F5,NOTE_F5,NOTE_FH1,NOTE_FH1,NOTE_FH1,NOTE_FH1,
  NOTE_FH2,NOTE_FH2,NOTE_FH2,NOTE_FH2,NOTE_FH2,NOTE_FH2,NOTE_FH2,NOTE_FH2,
  NOTE_F5,NOTE_F4,NOTE_F3,NOTE_F1,NOTE_F2,NOTE_0,NOTE_F2,NOTE_F6,
  NOTE_F5,NOTE_0,NOTE_F4,NOTE_0,NOTE_F3,NOTE_0,NOTE_F3,NOTE_F3,NOTE_F5,NOTE_0,NOTE_F4,NOTE_F3,NOTE_F2,NOTE_0,NOTE_F2,NOTE_FH4,
  NOTE_FH3, NOTE_FH4, NOTE_FH3, NOTE_FH4, NOTE_F2, NOTE_0,NOTE_F2,NOTE_FH4, NOTE_FH3, NOTE_FH4, NOTE_FH3, NOTE_FH4, NOTE_F2, NOTE_0,NOTE_F2,NOTE_F6,
  NOTE_F5,NOTE_0,NOTE_F4,NOTE_0,NOTE_F3,NOTE_0,NOTE_F3,NOTE_F3,NOTE_F5,NOTE_0,NOTE_F4,NOTE_F3,NOTE_F2,NOTE_0,NOTE_F2,NOTE_FH4,
  NOTE_FH3, NOTE_FH4, NOTE_FH3, NOTE_FH4, NOTE_F2, NOTE_0,NOTE_F2,NOTE_FH4,NOTE_FH3, NOTE_FH4, NOTE_FH3, NOTE_FH4,
};
float durt[]=                   //根据简谱列出各节拍
{
  0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5, 
  0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5, 
  0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5, 
  0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5, 
  0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5, 
  0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5, 
  0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5, 
  0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,
  0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5, 
  0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5, 
  0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5, 
  0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5
};

int length;//这里定义一个变量，后面用来表示共有多少个音符 
int tonepin=2;//蜂鸣器的pin  
void setup() {   
  pinMode(tonepin,OUTPUT);//设置蜂鸣器的pin为输出模式   
  length = sizeof(tune)/sizeof(tune[0]);//这里用了一个sizeof函数，可以查出tone序列里有多少个音符 
} 

void loop()
{ 
  for(int x=0;x<length;x++)
  {
    tone(tonepin,tune[x]);
    delay(500*durt[x]);   //这里用来根据节拍调节延时，500这个指数可以自己调整，在该音乐中，我发现用500比较合适。
    noTone(tonepin);
  }

}
